// ----------------------------------------------------------------------------
// Include the main OGRE header files
// Ogre.h just expands to including lots of individual OGRE header files
// ----------------------------------------------------------------------------
#include <Ogre.h>

// ----------------------------------------------------------------------------
// Include the main XGE header files
// XGE.h just expands to including lots of individual XGE header files
// ----------------------------------------------------------------------------
#include <XGE.h>
#include <XGE_Components.h>
#include "Components.h"
#include "States.h"

// ----------------------------------------------------------------------------
// Main function, just boots the application object
// ----------------------------------------------------------------------------
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT )
#else
int main(int argc, char **argv)
#endif
{
    // Create application object
    XGE::Overlord* o = new XGE::Overlord("Unlimited Worlds");

    try
    {
        XGE::ObjectManager* objectMan = new XGE::ObjectManager("Object Manager");
        XGE::StateManager* stateMan = new XGE::StateManager("State Manager");

        objectMan->registerComponentType(new XGE::OC::Null);

        if(o->init())
        {
            o->execute();
        }
    }
    catch( Ogre::Exception& e )
    {
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
        MessageBox( NULL, e.getFullDescription().c_str(), "An exception has occured!", MB_OK | MB_ICONERROR | MB_TASKMODAL);
#else

        std::cerr << "An exception has occured: " << e.getFullDescription();
#endif
    }

    delete o;

    return 0;
}
